package com.fs.system.manager.controller;

import com.fs.system.common.ResponseData;
import com.fs.system.manager.service.MessageService;
import com.fs.system.manager.domain.Message;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/messageWithRole")
public class MessageController {

    @Resource
    private MessageService messageService;

    /**
     * 根据id查询消息
     * @param id
     * @return
     */
    @GetMapping("/getMessageById")
    public ResponseData getMessageById(@RequestParam Long id) {
        Message dbMessage = messageService.getMessageById(id);
        return new ResponseData("200","获取成功",dbMessage);
    }

    /**
     * 根据不同角色的用户id与角色获取自己的消息
     * @param roleId
     * @return
     */
    @GetMapping("/getMessageByRoleId")
    public ResponseData getMessageByRoleId(@RequestParam Long roleId,@RequestParam String role) {
        List<Message> messagePersonList = messageService.getMessageByRoleId(roleId,role);
        return new ResponseData("200","获取成功",messagePersonList);
    }

    /**
     * 教师初审通过，向学生发送初审通过信息
     * @param stuId：学生id
     * @param teaId：教师id
     * @return
     */
    @PostMapping("/teaAddSuccessMessToStu")
    public ResponseData teaAddSuccessMessToStu(@RequestParam Long stuId, @RequestParam Long teaId) {
        messageService.teaAddSuccessMessToStu(stuId,teaId);
        return new ResponseData("200","发送成功");
    }

    /**
     * 教师初审打回，向学生发送初审打回信息
     * @param stuId：学生id
     * @param teaId：教师id
     * @return
     */
    @PostMapping("/teaAddErrorMessToStu")
    public ResponseData teaAddErrorMessToStu(@RequestParam Long stuId, @RequestParam Long teaId) {
        messageService.teaAddErrorMessToStu(stuId,teaId);
        return new ResponseData("200","发送成功");
    }

    /**
     * 院管理员终审通过，向学生发送终审通过信息
     * @param adminId 院管理员id
     * @param stuId 学生id
     * @return
     */
    @PostMapping("/adminAddSuccessMessToStu")
    public ResponseData adminAddSuccessMessToStu(@RequestParam Long stuId,@RequestParam Long adminId) {
        System.out.println("发送终审通过信息");
        messageService.adminAddSuccessMessToStu(stuId,adminId);
        return new ResponseData("200","发送成功");
    }

    /**
     * 院管理员批量终审通过，批量向学生发送终审通过信息
     * @param adminId 院管理员id
     * @param stuIds 学生id数组
     * @return
     */
    @PostMapping("/adminAddSuccessMessToStuBatch/{adminId}")
    public ResponseData adminAddSuccessMessToStuBatch(@PathVariable Long adminId,@RequestBody List<Long> stuIds) {
        messageService.adminAddSuccessMessToStuBatch(adminId,stuIds);
        return new ResponseData("200","发送成功");
    }

    /**
     * 院管理员终审打回，向学生发送终审打回信息
     * @param adminId 院管理员id
     * @param stuId 学生id
     * @return
     */
    @PostMapping("/adminAddErrorMessToStu")
    public ResponseData adminAddErrorMessToStu(@RequestParam Long stuId,@RequestParam Long adminId) {
        System.out.println("发送终审打回信息");
        messageService.adminAddErrorMessToStu(stuId,adminId);
        return new ResponseData("200","发送成功");
    }

    /**
     * 院管理员批量终审打回，批量向学生发送终审打回信息
     * @param adminId 院管理员id
     * @param stuIds 学生id数组
     * @return
     */
    @PostMapping("/adminAddErrorMessToStuBatch/{adminId}")
    public ResponseData adminAddErrorMessToStuBatch(@PathVariable Long adminId,@RequestBody List<Long> stuIds) {
        messageService.adminAddErrorMessToStuBatch(adminId,stuIds);
        return new ResponseData("200","发送成功");
    }

    /**
     * 院管理员执行分配审核操作后，向教师发送待审核消息通知
     * @param adminId 院管理员id
     * @param teaId 教师id
     * @return
     */
    @PostMapping("/adminAddGivenMessToTea")
    public ResponseData adminAddGivenMessToTea(@RequestParam Long teaId,@RequestParam Long adminId) {
        messageService.adminAddGivenMessToTea(teaId,adminId);
        return new ResponseData("200","发送成功");
    }

    /**
     * 院管理员执行分配审核操作后，向学生发送已分配消息通知
     * @param adminId 院管理员id
     * @param stuId 学生id
     * @return
     */
    @PostMapping("/adminAddGivenMessToStu")
    public ResponseData adminAddGivenMessToStu(@RequestParam Long stuId,@RequestParam Long adminId) {
        messageService.adminAddGivenMessToStu(stuId,adminId);
        return new ResponseData("200","发送成功");
    }

}
